home *** CD-ROM | disk | FTP | other *** search
Wrap
// Dungeon Keeper Install Shield 3 installation script // RReed Feb 22,'97 // Note: Localization taken from the registery declare // IMPORTANT GAME STUFF #define COMPANY_NAME "Bullfrog Productions Ltd" #define PRODUCT_NAME "Dungeon Keeper Demo" #define PRODUCT_VERSION "1.0" #define PRODUCT_KEY "Keeper Demo" #define DEINSTALL_KEY "Keeper Demo" #define DEFAULT_PATH "\\Program Files\\Bullfrog\\Keeper Demo\\" #define SETSOUND_PATH "\\Program Files\\Bullfrog\\" #define CONFIG_FILENAME "Keeper.Cfg" #define LANGUAGE_ID "ENG" #define EXE_95 "keeper95.exe" // #define EXE_95 "keeper.exe" //Make it copy DOS exe for now #define COPY_SAVE "Creating game save directory..." #define FILESET_NAME "THE_FILES" // DIRECT X STUFF #define DIRECTX_LICENSE_FILE "DXLicens.txt" // SPACE REQUIRED STUFF #define MINIMAL_INSTALL_SPACE 10000000 #define TYPICAL_INSTALL_SPACE 25000000 #define FULL_INSTALL_SPACE 45000000 #define DIRECTX_SPACE 10000000 #define MINIMAL_INSTALL "Minimal" #define TYPICAL_INSTALL "Typical" #define FULL_INSTALL "Full" // GLOBAL VARIABLES STRING targetDir; STRING directXRedist; STRING AWE32Redist; STRING components; STRING uninstLog; STRING install_type; NUMBER file_handle; STRING scratch; BOOL needReboot; STRING installer_disk_root; NUMBER temp; STRING AWE32Exists; // Localized strings STRING sBackgroundCaption; STRING sDoneText; STRING sInstallComplete; STRING sMinimalInstall; STRING sTypicalInstall; STRING sFullInstall; STRING sSoundSetup; STRING sWhichInstall; STRING sAskDirectX; STRING sAskAWE32; STRING sBadOSVersion; STRING sNoCDROM; STRING sHas386Proc; STRING sNoDirectXSpace; STRING sNoInstallSpace; STRING sRebootText; STRING sMiscFileError; STRING sDirectXLicenseTitle; STRING sDirectXLicenseMsg; STRING sDirectXLicenseQuestion; STRING sCopyExe; STRING sCopyData; STRING sCopySound; #define DONE_TEXT "Dungeon Keeper Demo has been successfully installed.\nYou can launch it from the Windows Start menu." // FUNCTIONS prototype InitStrings(); prototype SetupScreen(); prototype CheckSystem(); prototype WelcomeStuff(); prototype InstallDirectX(); prototype InstallAWE32(); prototype ChooseInstallType(); prototype SetTargetDirectory(); prototype SetupFileSetAndRegistry(); prototype TransferFiles(); prototype CreateConfigFile(); prototype AddFolderIcons(); prototype FinalStuff(); #include "sddialog.h" //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- program StartHere: Disable( BACKGROUND ); Disable( BACKBUTTON ); Enable( DIALOGCACHE ); // This is what we're installing! InstallationInfo(COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY); directXRedist = SRCDIR ^ "..\\Redist\\"; AWE32Redist = SRCDIR ^ "..\\Redist\\Creative\\"; InitStrings(); SetupScreen(); CheckSystem(); WelcomeDialog: WelcomeStuff(); InstallDirectX(); // InstallAWE32(); ChooseInstall: // if ( ChooseInstallType() = BACK) then // goto WelcomeDialog; // endif; SetTargetDir: if (SetTargetDirectory() = BACK) then goto ChooseInstall; endif; SetupFileSetAndRegistry(); if (TransferFiles() = BACK) then goto ChooseInstall; endif; // CreateConfigFile(); AddFolderIcons(); FinalStuff(); exit; //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- function InitStrings() LIST textList; begin textList = ListCreate(STRINGLIST); ListReadFromFile(textList, SRCDIR ^ "iText.txt"); ListGetFirstString(textList, sBackgroundCaption); ListGetNextString(textList, sDoneText); ListGetNextString(textList, sInstallComplete); ListGetNextString(textList, sMinimalInstall); ListGetNextString(textList, sTypicalInstall); ListGetNextString(textList, sFullInstall); ListGetNextString(textList, sSoundSetup); ListGetNextString(textList, sWhichInstall); ListGetNextString(textList, sAskDirectX); ListGetNextString(textList, sBadOSVersion); ListGetNextString(textList, sNoCDROM); ListGetNextString(textList, sHas386Proc); ListGetNextString(textList, sNoDirectXSpace); ListGetNextString(textList, sNoInstallSpace); ListGetNextString(textList, sRebootText); ListGetNextString(textList, sMiscFileError); ListGetNextString(textList, sDirectXLicenseTitle); ListGetNextString(textList, sDirectXLicenseMsg); ListGetNextString(textList, sDirectXLicenseQuestion); ListGetNextString(textList, sCopyExe); ListGetNextString(textList, sCopyData); ListGetNextString(textList, sCopySound); ListGetNextString(textList, sAskAWE32); //ListGetNextString(textList, ); ListDestroy ( textList ); end; //-------------------------------------------------------------------------------------------------- function SetupScreen() STRING backBmp; begin Enable(FULLWINDOWMODE); Enable(INDVFILESTATUS); Enable(BITMAP256COLORS); SetTitle(sBackgroundCaption, 24, WHITE); backBmp = SRCDIR ^ "..\\art\\back.bmp"; PlaceBitmap ( backBmp, 0, CENTERED, CENTERED, CENTERED ); SetColor(BACKGROUND, RGB(0,0,0)); // SetColor(BACKGROUND, BK_RED ); // SetColor(STATUSBAR, RED ); Enable( BACKGROUND ); Delay( 2 ); end; //-------------------------------------------------------------------------------------------------- function CheckSystem() NUMBER nresult; STRING sresult; begin // Check some basic system requirements GetSystemInfo(OS , nresult , sresult); if ( nresult != IS_WINDOWSNT && nresult != IS_WINDOWS95 ) then MessageBox( sBadOSVersion , SEVERE ); exit; endif; if ( nresult = IS_WINDOWSNT ) then GetSystemInfo( OSMAJOR , nresult , sresult ); if ( nresult < 4 ) then MessageBox( sBadOSVersion , SEVERE ); exit; endif; endif; GetSystemInfo( CDROM , nresult , sresult ); if ( nresult = FALSE ) then MessageBox( sNoCDROM , SEVERE ); exit; endif; GetSystemInfo( CPU , nresult , sresult ); if ( nresult = IS_386 ) then MessageBox( sHas386Proc , SEVERE ); exit; endif; end; //-------------------------------------------------------------------------------------------------- function WelcomeStuff() begin // Create a Welcome dialog. Disable( BACKBUTTON ); Welcome( "", 0 ); Enable( BACKBUTTON ); end; //-------------------------------------------------------------------------------------------------- function InstallDirectX() begin // Install DirectX if ( AskYesNo( sAskDirectX , YES ) = YES ) then if ( GetDiskSpace( WINDISK ) < DIRECTX_SPACE ) then MessageBox( sNoDirectXSpace , SEVERE ); exit; endif; // Ask about the DirectX licence agreement Disable( BACKBUTTON ); SdLicense( sDirectXLicenseTitle , sDirectXLicenseMsg , sDirectXLicenseQuestion , SRCDIR ^ DIRECTX_LICENSE_FILE ); Enable( BACKBUTTON ); LaunchAppAndWait( directXRedist ^ "InstDX.exe" , "" , WAIT ); needReboot = TRUE; endif; end; //-------------------------------------------------------------------------------------------------- function InstallAWE32() NUMBER type, lang, length, retVal; STRING regEntry; begin AWE32Exists = "1"; // Check AWE32 exists LaunchAppAndWait( AWE32Redist ^ "ctdetect.exe" , "" , WAIT ); RegDBSetDefaultRoot(HKEY_CURRENT_USER); if (RegDBGetKeyValueEx("\\Software\\Bullfrog Productions Ltd\\Audio", "Awe32Detected", type, regEntry, length) = 0) then // read the language set from the registry if (StrCompare(regEntry, AWE32Exists) = 0) then if ( AskYesNo( sAskAWE32 , YES ) = YES ) then LaunchAppAndWait( AWE32Redist ^ "upddrv95.exe" , "" , WAIT ); needReboot = TRUE; endif; endif; endif; end; //-------------------------------------------------------------------------------------------------- function ChooseInstallType() begin // Choose which kind of installation components = "Keeper"; ComponentAddItem( components , sMinimalInstall , MINIMAL_INSTALL_SPACE, FALSE ); ComponentAddItem( components , sTypicalInstall , TYPICAL_INSTALL_SPACE, TRUE ); ComponentAddItem( components , sFullInstall , FULL_INSTALL_SPACE, FALSE ); return SdAskOptions( "" , sWhichInstall , "" , "" , components , EXCLUSIVE ); end; //-------------------------------------------------------------------------------------------------- function SetTargetDirectory() NUMBER retVal; begin // Ask user for target directory... targetDir = TARGETDISK ^ DEFAULT_PATH; retVal = AskDestPath( "" , "" , targetDir , 0 ); // ...then check disk space for the install if (retVal = NEXT) then if ( ComponentIsItemSelected( components , sMinimalInstall ) ) then if ( GetDiskSpace( targetDir ) < MINIMAL_INSTALL_SPACE ) then MessageBox( sNoInstallSpace , WARNING ); retVal = BACK; endif; endif; if ( ComponentIsItemSelected( components , sTypicalInstall ) ) then if ( GetDiskSpace( targetDir ) < TYPICAL_INSTALL_SPACE ) then MessageBox( sNoInstallSpace , WARNING ); retVal = BACK; endif; endif; if ( ComponentIsItemSelected( components , sFullInstall ) ) then if ( GetDiskSpace( targetDir ) < FULL_INSTALL_SPACE ) then MessageBox( sNoInstallSpace , WARNING ); retVal = BACK; endif; endif; endif; return retVal; end; //-------------------------------------------------------------------------------------------------- function SetupFileSetAndRegistry() LIST copyList; STRING copyString; begin // // Set registry keys // RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE ); // RegDBSetItem( REGDB_APPPATH , targetDir ); // RegDBSetItem( REGDB_APPPATH_DEFAULT , targetDir ^ EXE_95 ); // Define the file set FileSetBeginDefine(FILESET_NAME); StatusUpdate(ON, 100); SetStatusWindow(-1 , sCopyExe ); FileSetRoot( FILESET_NAME , SRCDIR ^ "..\\..\\..\\Keeper" ); //SprintfBox (INFORMATION, "Source Directory is:", "%s", SRCDIR ^ "..\\..\\..\\Keeper"); TARGETDIR = targetDir; CopyFile("KEEPER95.EXE", "KEEPER95.EXE"); CopyFile("MSS32.DLL", "MSS32.DLL"); CopyFile("DSETUP16.DLL", "DSETUP16.DLL"); CopyFile("DSETUP.DLL", "DSETUP.DLL"); CopyFile("SMACKW32.DLL", "SMACKW32.DLL"); CopyFile("WSND7R.DLL", "WSND7R.DLL"); //------------------------------------------ // Let's copy the sound files SetStatusWindow(-1 , sCopySound ); FileSetRoot( FILESET_NAME , SRCDIR ^ "..\\..\\..\\Keeper\\sound" ); copyList = ListCreate(STRINGLIST); ListReadFromFile(copyList, SRCDIR ^ "listsnd.txt"); TARGETDIR = targetDir ^ "sound\\"; temp = ListGetFirstString(copyList, copyString); //SprintfBox (INFORMATION, "Copy String", "The current copyString is: %s", copyString); while ( temp = 0 ) CopyFile(copyString, copyString); temp = ListGetNextString(copyList, copyString); // SprintfBox (INFORMATION, "Copy String", "The current copyString is: %s", copyString); endwhile; ListDestroy ( copyList ); //------------------------------------------ //Now the atlas sound files // FileSetRoot( FILESET_NAME , SRCDIR ^ "..\\..\\..\\Keeper\\sound\\atlas\\english" ); //SprintfBox (INFORMATION, "Atlas FileSetRoot", "%s", SRCDIR ); // copyList = ListCreate(STRINGLIST); // ListReadFromFile(copyList, SRCDIR ^ "listatla.txt"); // TARGETDIR = targetDir ^ "sound\\atlas\\"; // temp = ListGetFirstString(copyList, copyString); // while ( temp = 0 ) //SprintfBox ( INFORMATION, "CopyString", "%s", copyString); // CopyFile(copyString, copyString); // temp = ListGetNextString(copyList, copyString); // endwhile; // ListDestroy ( copyList ); //------------------------------------------ //Now the localised speech file FileSetRoot( FILESET_NAME , SRCDIR ^ "..\\..\\..\\Keeper\\sound\\speech\\english" ); TARGETDIR = targetDir ^ "sound\\"; CopyFile("speech.dat", "speech.dat"); //------------------------------------------ //Now the main data files SetStatusWindow(-1 , sCopyData ); FileSetRoot( FILESET_NAME , SRCDIR ^ "..\\..\\..\\Keeper\\data" ); copyList = ListCreate(STRINGLIST); ListReadFromFile(copyList, SRCDIR ^ "listdat.txt"); TARGETDIR = targetDir ^ "data\\"; temp = ListGetFirstString(copyList, copyString); while ( temp = 0 ) CopyFile(copyString, copyString); temp = ListGetNextString(copyList, copyString); endwhile; ListDestroy ( copyList ); //------------------------------------------ //Now the localised text file SetStatusWindow(-1 , sCopyData ); FileSetRoot( FILESET_NAME , SRCDIR ^ "..\\..\\..\\Keeper\\data\\english" ); TARGETDIR = targetDir ^ "data\\"; CopyFile("text.dat", "text.dat"); //------------------------------------------ //Now the localised readme file // FileSetRoot( FILESET_NAME , SRCDIR ^ "..\\..\\..\\Keeper\\Readme\\English" ); // TARGETDIR = targetDir; // CopyFile("readme.txt", "readme.txt"); //------------------------------------------ //Now the ldata files FileSetRoot( FILESET_NAME , SRCDIR ^ "..\\..\\..\\Keeper\\Ldata" ); //SprintfBox (INFORMATION, "Source Directory is:", "%s", SRCDIR ^ "..\\..\\..\\Keeper"); TARGETDIR = targetDir ^ "Ldata\\"; CopyFile("FRONT.PAL", "FRONT.PAL"); CopyFile("FRONT.RAW", "FRONT.RAW"); CopyFile("FRONTBIT.DAT", "FRONTBIT.DAT"); CopyFile("FRONTBIT.TAB", "FRONTBIT.TAB"); CopyFile("FRONTFT1.DAT", "FRONTFT1.DAT"); CopyFile("FRONTFT1.TAB", "FRONTFT1.TAB"); CopyFile("FRONTFT2.DAT", "FRONTFT2.DAT"); CopyFile("FRONTFT2.TAB", "FRONTFT2.TAB"); CopyFile("FRONTFT3.DAT", "FRONTFT3.DAT"); CopyFile("FRONTFT3.TAB", "FRONTFT3.TAB"); CopyFile("FRONTFT4.DAT", "FRONTFT4.DAT"); CopyFile("FRONTFT4.TAB", "FRONTFT4.TAB"); CopyFile("HISCORES.DAT", "HISCORES.DAT"); CopyFile("INTROMIX.SMK", "INTROMIX.SMK"); CopyFile("LOADING.PAL", "LOADING.PAL"); CopyFile("LOADING.RAW", "LOADING.RAW"); //------------------------------------------ //Now the level files FileSetRoot( FILESET_NAME , SRCDIR ^ "..\\..\\..\\Keeper\\Levels" ); TARGETDIR = targetDir ^ "Levels\\"; CopyFile("LEVELS.TXT", "LEVELS.TXT"); CopyFile("MAP00001.ANM", "MAP00001.ANM"); CopyFile("MAP00001.APT", "MAP00001.APT"); CopyFile("MAP00001.BAK", "MAP00001.BAK"); CopyFile("MAP00001.CEI", "MAP00001.CEI"); CopyFile("MAP00001.CLM", "MAP00001.CLM"); CopyFile("MAP00001.CUB", "MAP00001.CUB"); CopyFile("MAP00001.DAT", "MAP00001.DAT"); CopyFile("MAP00001.DOR", "MAP00001.DOR"); CopyFile("MAP00001.EFF", "MAP00001.EFF"); CopyFile("MAP00001.ERR", "MAP00001.ERR"); CopyFile("MAP00001.FLG", "MAP00001.FLG"); CopyFile("MAP00001.INF", "MAP00001.INF"); CopyFile("MAP00001.LGT", "MAP00001.LGT"); CopyFile("MAP00001.OLD", "MAP00001.OLD"); CopyFile("MAP00001.ORI", "MAP00001.ORI"); CopyFile("MAP00001.OWN", "MAP00001.OWN"); CopyFile("MAP00001.ROM", "MAP00001.ROM"); CopyFile("MAP00001.SLB", "MAP00001.SLB"); CopyFile("MAP00001.SWT", "MAP00001.SWT"); CopyFile("MAP00001.TMN", "MAP00001.TMN"); CopyFile("MAP00001.TNG", "MAP00001.TNG"); CopyFile("MAP00001.TXT", "MAP00001.TXT"); CopyFile("MAP00001.VSN", "MAP00001.VSN"); CopyFile("MAP00001.WIB", "MAP00001.WIB"); CopyFile("MAP00001.WLB", "MAP00001.WLB"); CopyFile("MAP00001.ZON", "MAP00001.ZON"); //------------------------------------------ // Save // SetStatusWindow( -1 , COPY_SAVE ); // CreateDir ( targetDir ^ "Save" ); // FileSetRoot( "FileSet" , SRCDIR ); // TARGETDIR = targetDir ^ "Save\\"; // CopyFile( "HiScore.dat" , "HiScore.dat" ); //------------------------------------------ //SetStatusWindow(-1 , sCopySound ); //FileSetRoot( FILESET_NAME , SRCDIR ^ "..\\..\\..\\Keeper\\sound" ); //TARGETDIR = targetDir ^ "sound\\"; //XCopyFile("*.*", "", INCLUDE_SUBDIR); //SetStatusWindow(-1 , sCopyData ); //FileSetRoot( FILESET_NAME , SRCDIR ^ "..\\..\\..\\Keeper\\data" ); //TARGETDIR = targetDir ^ "data\\"; //XCopyFile("*.*", "", INCLUDE_SUBDIR); FileSetRoot( FILESET_NAME , "" ); FileSetEndDefine(FILESET_NAME); end; //-------------------------------------------------------------------------------------------------- function TransferFiles() NUMBER retVal; NUMBER blah; begin retVal = NEXT; // Do all the file copying // Prepare InstallShield to record deinstallation information. DeinstallStart( "C:\\WINDOWS\\SYSTEM\\KEEPER" , uninstLog , DEINSTALL_KEY, 0 ); blah = RegDBSetItem( REGDB_UNINSTALL_NAME, PRODUCT_NAME ); //SprintfBox ( INFORMATION, "Uninstall return", "Install file: %s return: %d", PRODUCT_NAME, blah ); // Set up progress indicator and information gauge. Disable( DIALOGCACHE ); Enable( STATUSDLG ); Enable( STATUS ); SetStatusWindow( 1 , " " ); StatusUpdate( OFF , 1 ); // Install the files SetStatusWindow( 1 , " " ); //------------------------- StatusUpdate( ON , 100 ); blah = FileSetPerformEz( FILESET_NAME , 0 ); if ( blah < 0 ) then if ( blah = -1 ) then SprintfBox (INFORMATION, "Error", "Unknown error."); endif; if ( blah = -3 ) then SprintfBox (INFORMATION, "Error", "Unable to open output file. Restart your machine, then try installing again."); endif; if ( blah = -4 ) then SprintfBox (INFORMATION, "Error", "Unable to write to file. Make sure the correct source disk is chosen."); endif; if ( blah = -6 ) then SprintfBox (INFORMATION, "Error", "Memory allocation error.Close other applications, then try installing again."); endif; if ( blah = -9 ) then SprintfBox (INFORMATION, "Error", "Source and target directories conflict.Make sure that target directory is not the same as the source directory (unless this is intended)."); endif; if ( blah = -27 ) then SprintfBox (INFORMATION, "Error", "Unable to create directory. Check the content of your hard drive, and your access privileges to the drive and directory."); endif; if ( blah = -38 ) then SprintfBox (INFORMATION, "Error", "Not enough disk space on target drive.Free disk space on target drive, then try installing again."); endif; if ( blah = -46 ) then SprintfBox (INFORMATION, "Error", "Target file is read-only and cannot be overwritten."); endif; SprintfBox (INFORMATION, "Error", "There has been an error!"); retVal = BACK; endif; // if ( FileSetPerformEz( FILESET_NAME , 0 ) != 0 ) then // MessageBox( sMiscFileError , SEVERE ); // retVal = BACK; // endif; return retVal; end; //-------------------------------------------------------------------------------------------------- //Create the config file function CreateConfigFile() begin // if ( ComponentIsItemSelected ( components, MINIMAL_INSTALL )) then // install_type = "MIN"; // else if ( ComponentIsItemSelected ( components, TYPICAL_INSTALL )) then // install_type = "MED"; // else if ( ComponentIsItemSelected ( components, FULL_INSTALL )) then install_type = "MAX"; // endif; installer_disk_root = SRCDIR; StrRemoveLastSlash ( installer_disk_root ); ParsePath ( installer_disk_root, installer_disk_root, PATH ); StrRemoveLastSlash ( installer_disk_root ); ParsePath ( installer_disk_root, installer_disk_root, PATH ); OpenFileMode ( FILE_MODE_NORMAL ); if ( CreateFile ( file_handle, targetDir, CONFIG_FILENAME ) = 0 ) then Sprintf ( scratch, "INSTALL_PATH=%s", installer_disk_root ); WriteLine ( file_handle, scratch ); Sprintf ( scratch, "INSTALL_TYPE=%s", install_type ); WriteLine ( file_handle, scratch ); Sprintf ( scratch, "LANGUAGE=%s", LANGUAGE_ID ); WriteLine ( file_handle, scratch ); CloseFile ( file_handle ); endif; end; //-------------------------------------------------------------------------------------------------- function AddFolderIcons() STRING appPath; STRING uninstPath; STRING readmePath; begin // Create all the Start menu shortcuts // MessageBox ("Got to AddFolderIcons", INFORMATION); appPath = targetDir ^ EXE_95; LongPathToQuote( appPath , TRUE ); uninstPath = "C:\\WINDOWS\\UNINST"; LongPathToQuote ( uninstLog, TRUE ); uninstPath = uninstPath + " -f" + uninstLog; //SprintfBox (INFORMATION, "UNINST PATH", "Path = %s", uninstPath); readmePath = targetDir ^ "readme.txt"; LongPathToQuote( readmePath , TRUE ); AddFolderIcon( "Bullfrog\\Dungeon Keeper Demo" , PRODUCT_NAME , appPath , targetDir , targetDir ^ EXE_95 , 0 , "" , REPLACE|RUN_MAXIMIZED ); // AddFolderIcon( "Bullfrog\\Dungeon Keeper" , "Readme.txt" , readmePath , targetDir , targetDir ^ "readme.txt", 0 , "" , REPLACE ); AddFolderIcon( "Bullfrog\\Dungeon Keeper Demo" , "unInstall Dungeon Keeper Demo" , uninstPath , targetDir , "C:\\WINDOWS\\UNINST.EXE" , 0 , "" , REPLACE ); // Set registry keys RegDBSetDefaultRoot ( HKEY_LOCAL_MACHINE ); RegDBSetItem( REGDB_APPPATH , targetDir ); RegDBSetItem( REGDB_APPPATH_DEFAULT , targetDir ^ EXE_95 ); end; //-------------------------------------------------------------------------------------------------- function FinalStuff() begin if ( needReboot = TRUE ) then SdFinishReboot( "" , sRebootText , SYS_BOOTWIN , "" , 0 ); else MessageBox( DONE_TEXT, INFORMATION ); endif; end; //-------------------------------------------------------------------------------------------------- #include "sddialog.rul"